﻿using System;

namespace DBMock.Builders.Attributes
{
    /// <summary>
    /// 日期builder特性
    /// </summary>
    [AttributeUsage(AttributeTargets.Property, AllowMultiple = true)]
    public class DateTimeBuilderAttribute : BaseBuilderAttribute
    {
        /// <summary>
        /// 初始化DateTimeBuilderAttribute
        /// </summary>
        /// <param name="minTime">最小值</param>
        /// <param name="maxTime">最大值</param>
        public DateTimeBuilderAttribute(string minTime = "1977.1.1", string maxTime = "2057.1.1")
            : base(typeof(DateTimeBuilder))
        {
            DateTime min;
            DateTime max;

            if (!DateTime.TryParse(minTime, out min))
            { min = new DateTime(1977, 1, 1); }

            if (!DateTime.TryParse(maxTime, out max))
            { max = new DateTime(2057, 1, 1); }

            para = new object[] { min, max };
        }
    }
}
